package com.ts.config;

import com.qf.constatns.RabbitMQConstatns;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMQConfig {

    // 创建一个交换机
    @Bean
    public FanoutExchange goodsExchange() {
        return new FanoutExchange(RabbitMQConstatns.GOODS_EXCHAGNE, true, false);
    }

    // 创建一个队列
    @Bean
    public Queue goodsEsQueue() {
        return new Queue(RabbitMQConstatns.GOODS_ES_QUEUE, true, false, false);
    }

    @Bean
    public Binding goodsEsQueueBindGoodsExchange() {
        return BindingBuilder.bind(goodsEsQueue()).to(goodsExchange());
    }
}
